home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8522 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.3 KB  |  69 lines

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: gnu.gcc.help,comp.lang.c
  4. Subject: Re: Is this a compiler bug?
  5. Date: 02 Mar 1996 19:49:11 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar2124911@qcd.lanl.gov>
  8. References: <3135FEDB.65AA@carbon.chem.nyu.edu> <4h991r$qon@segfault.monkeys.com>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: rfg@monkeys.com's message of 2 Mar 1996 02:48:27 -0800
  13.  
  14. In article <4h991r$qon@segfault.monkeys.com>
  15. rfg@monkeys.com (Ronald F. Guilmette) writes:
  16.  
  17. <snip>
  18. RFG: >carbon% head static*.c
  19. RFG: >==> static_bug.c <==
  20. RFG: >static const char foo[];
  21. RFG: >
  22. RFG: >int
  23. RFG: >main(int argc, const char *argv[]) {
  24. RFG: >  printf("foo = '%s'\n",foo);
  25. RFG: >  return 0;
  26. RFG: >}
  27. RFG: >
  28. RFG: >#ifdef DEFINE_IT
  29. RFG: >static const char foo[] = "bar";
  30. RFG: >#endif
  31. RFG: >
  32. RFG: >==> static_bug2.c <==
  33. RFG: >const char foo[] = "baz";
  34. RFG: >carbon% gcc static*.c
  35. RFG: >carbon% a.out
  36. RFG: >foo = 'baz'
  37. RFG: 
  38. RFG: I believe that in this case, the proper ANSI required behavior would be to
  39. RFG: print:
  40. RFG: 
  41. RFG:     foo = ''
  42.  
  43. No. It is undefined.
  44.  
  45. RFG: 
  46. RFG: because there is some special clause in the C standard about tenative
  47. RFG: declarations (e.g. your first declaration of the `foo' array) and their
  48. RFG: handling at the end of a translation unit (i.e. `static_bug.c') in cases
  49. RFG: where no non-tenative declaration/definition has been provided... and that
  50. RFG: rule says that the compiler must act as if the data object in question
  51. RFG: has an initializer of zero.  Thus, I believe that the compiler should
  52. RFG: simulate the following definition at the end of the translation unit
  53. RFG: unit `static_bug.c':
  54. RFG: 
  55. RFG:     static const char foo[] = { 0 };
  56.  
  57. Except that a tentative declaration of an identifier with internal
  58. linkage cannot specify an incomplete type.
  59.  
  60. Cheers
  61. Tanmoy
  62. --
  63. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  64. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  65. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  66. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  67. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  68. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  69.